package ecode

import "fmt"

type TaskError struct {
	Code int
	Msg  string
}

func (t TaskError) Error() string {
	return fmt.Sprintf("code: %d, msg: %s", t.Code, t.Msg)
}

func New(code int, msg string) TaskError {
	return TaskError{
		Code: code,
		Msg:  msg,
	}
}

var (
	// common 1000~1999
	ParamsError = New(1001, "参数错误")
	EngineError = New(1002, "数据库错误")
	PulsarError = New(1003, "消息队列错误")
	DataError   = New(1004, "数据错误")
	RPCError    = New(1005, "RPC请求错误")

	// resource 2000 ~ 2999
	ResourceNotFound = New(2001, "资源不存在")

	// dag & processor 3000 ~ 3999
	DagNotFound       = New(3001, "DAG不存在")
	ProcessorNotFound = New(3002, "处理单元不存在")

	// process 4000 ~ 4999
	DispatchEventNotFound = New(4001, "调度事件不存在")
	ExecutorHdlNotFound   = New(4002, "执行处理器不存在")
	ProcessStateNotFound  = New(4003, "处理状态不存在")
	ProcessStateWrong     = New(4004, "处理状态错误")
	DispatchMaxRetryTimes = New(4005, "调度达到最大重试次数")
)
